<template>
  <div class="add-warp">
    <div class="add-content">
      <el-form
        :model="ruleForm"
        ref="ruleForm"
        label-width="100px"
        class="demo-ruleForm"
      >
        <el-form-item label="品牌名称" prop="name">
          <el-input v-model="ruleForm.name" style="width: 220px"></el-input>
        </el-form-item>
        <el-form-item label="级别" prop="level">
          <el-input
            v-model="ruleForm.level"
            style="width: 220px"
            :disabled="true"
          ></el-input>
        </el-form-item>
        <el-form-item label="相关" prop="count">
          <el-input v-model="ruleForm.count" style="width: 220px"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="editBranch">提交</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
import { editSecond } from "@/http/commodity-management/classityApi";
export default {
  name: "TwoEdit",
  data() {
    return {
      ruleForm: {
        id: "",
        name: "",
        level: "二级",
        count: "",
        from: 3,
      },
      titleMsg: "",
    };
  },
  methods: {
    editBranch() {
      this.$confirm("是否确认此次操作?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "error",
      }).then(() => {
        editSecond(this.ruleForm)
          .then((res) => {
            console.log(res);
            this.$router.push({ path: "/goods/lookSubordinate" });
            this.$message({
              message: "修改成功",
              type: "success",
            });
          })
          .catch((err) => {
            console.log("修改失败", err);
          });
      });
    },
  },
  activated() {
    if (this.$route.query.obj) {
      let { name, count, id } = this.$route.query.obj;
      this.ruleForm.name = name;
      this.ruleForm.count = count;
      this.ruleForm.id = id;
    }
  },
  deactivated() {
    this.ruleForm = {
      id: "",
      name: "",
      level: "二级",
      count: "",
      from: 3,
    };
    this.$refs.ruleForm.resetFields();
  },
};
</script>

<style scoped lang="scss">
@import "@/assets/sass/var.scss";

.add-warp {
  .add-nav {
    height: 50px;
    background-color: rgba(243, 243, 243);
    line-height: 50px;
    span {
      margin-left: 20px;
    }
  }

  .add-content {
    width: 100%;
    margin: 50px;
  }
}
</style>